﻿//
	//函数
	function HJ$(aControlID){
		return document.getElementById(aControlID);
	}

	function ShiftVisible(aObjName){
		try{
			var targetElement=HJ$(aObjName);
			if (targetElement.style.display == "block" || targetElement.style.display == "") {
				targetElement.style.display = "none";
			} else {
				targetElement.style.display = "block";
			}
		}catch(e){
			alert(e.message);
		}
		return false;
	} 

	function TimeStringFormat(Time_int){
		var Mscon= Math.floor((Time_int/100) % 10 );
		Time_int=Math.round(Time_int/1000);
		var Scon=MatchNumber( Time_int % 60 );
		var Minu=MatchNumber( Math.floor(Time_int/60) );
		var Hour=MatchNumber( Math.floor(Time_int/3600) );
		if(Hour==0){
			return Minu+":"+ Scon + "."+ Mscon;
		}else{
			return Hour+":"+ Minu+":"+ Scon  + "."+ Mscon;
		}
	}
	function TimeStringFormat2(Time_int){
		var Scon=MatchNumber( Time_int % 60 );
		var Minu=MatchNumber( Math.floor(Time_int/60) );
		var Hour=MatchNumber( Math.floor(Time_int/3600) );
		if(Hour==0){
			return Minu+":"+ Scon;
		}else{
			return Hour+":"+ Minu+":"+ Scon ;
		}
	}	
	function MatchNumber(aNum){
		if(aNum<10){
			return "0"+aNum;
		}else{
			return aNum;
		}
	}

	//parems={pro:value,...}
	function QueryStrings(parems, aurl){ 
		if(!aurl){
			aurl =window.location.href;
		} 
		if(aurl.toLowerCase().split("?").length>1){
		    aurl =aurl.toLowerCase().split("?")[1];
	    }else{
	        aurl="";
	    }
		// 
		var retList={}; 
		if(aurl.toLowerCase().split("&").length>1){
		    var OldItems= aurl.split("&");
		    for(var i=0;i<OldItems.length;i++){
			    var proitem =OldItems[i].split("="); 
			    retList[ proitem[0] ]=proitem[1];
		    }
		}
		//
		for(var item in parems){  
			retList[ item ]= parems[item];
		}
		var retString = "";
		for(var item in retList){ 
			retString+= "&" +item +"="+ encodeURIComponent(retList[item]);
		}
		return "?"+ retString.substr(1, retString.length-1);  
	}
	
    //get query params
    function QueryString(akey){
        var reg=new RegExp(".*(?:\\?|&)"+ akey +"=(.*?)(?:$|&|#).*", "igm");
        var value=window.location.href.replace(reg, "$1");
        if(window.location.href==value){
            return "";
        }else{
            return value;
        }
    }
    function getAnchor(){ 
        if(document.location.href.indexOf("#")!=-1){
            var item = document.location.href.split("#").pop();
            if(item!=""){
                return item;
            }
        }
        return "";
    }
    function FormatDateString(adate){
        return adate.getFullYear() + "-"+ (adate.getMonth() +1)  +"-"+adate.getDate() +" "+adate.getHours() +":"+ Numtemplate(adate.getMinutes ());
    }
    function FormatTimeString(adate){
        return adate.getHours() +":"+ Numtemplate(adate.getMinutes ());
    }
    //沪江网摘
    function AddHjLink(){
        d=document;
        t=d.selection?(d.selection.type!='None'?d.selection.createRange().text:''):(d.getSelection?d.getSelection():'');void(keyit=window.open('http://bulo.hjenglish.com/link/storeit.aspx?t='+escape(d.title)+'&u='+escape(d.location.href)+'&c='+escape(t),'keyit','scrollbars=no,width=420,height=460,left=75,top=20,menu=yes,status=no,resizable=yes'));keyit.focus();
    }
    //
    function getcookie(name) {
	    var cookie_start = document.cookie.indexOf(name);
	    var cookie_end = document.cookie.indexOf(";", cookie_start);
	    return cookie_start == -1 ? '' : unescape(document.cookie.substring(cookie_start + name.length + 1, (cookie_end > cookie_start ? cookie_end : document.cookie.length)));
    }
    function setcookie(cookieName, cookieValue, seconds, path, domain, secure) {
	    var expires = new Date();
	    expires.setTime(expires.getTime() + seconds*1000);
	    document.cookie = escape(cookieName) + '=' + escape(cookieValue)
		    + (expires ? '; expires=' + expires.toGMTString() : '')
		    + (path ? '; path=' + path : '/')
		    + (domain ? '; domain=' + domain : '')
		    + (secure ? '; secure' : '');
    }
	function Numtemplate(aInt){
		if(aInt<10){
			return "0"+aInt;
		}else{
			return aInt;
		}
	}
	function GetDate(aDate){
	    if(!aDate){
		    aDate=new Date();
	    }
		return aDate.getFullYear()+"-"+ Numtemplate(aDate.getMonth()+1 )+"-"+ Numtemplate(aDate.getDate());
	}
	function GetfullDate(aDate){
	    if(!aDate){
		    aDate=new Date();
	    }
		return aDate.getFullYear()+ Numtemplate(aDate.getMonth()+1 )+ Numtemplate(aDate.getDate());
	}
	//通用的复制代码
    var Clipboard=0; 
    function GetClipboard(){  
	    return Clipboard;
    }
    function copyit(textit) {
	    Clipboard=textit;
	    if (window.clipboardData) {
		    window.clipboardData.setData("Text",textit);
	    } else {
		    var flashcopier = 'flashcopier';
		    if(!HJ$(flashcopier)) {
			    var divholder = document.createElement('div');
			    divholder.id = flashcopier;
			    document.body.appendChild(divholder);
		    }
		    HJ$(flashcopier).innerHTML = '';
		    var divinfo = '<embed src="/common/_clipboard.swf" width="0" height="0" type="application/x-shockwave-flash" id="flashforcopy" name="flashforcopy"></embed>';
		    HJ$(flashcopier).innerHTML = divinfo; 
	    }
    }
    function Score2Money(aScore, aisActiving, atimeused){
        if(aisActiving){
            if(atimeused<300){
                return 5;
            }else{
                return Math.max(5, (aScore-60)/2 +5);
            }
        }else{
            return 0;
        }
    }
    //通用的复制代码 结束 
    function ShowTopUser(){ 
        if($("#panel_rally").css("display")=="block"){
            $("#panel_rally").slideUp("fast"); 
			try{$('#form_search').find("#pid").css("display", "inline");}catch(e){}
			try{$('#latest_ctn').css("display", "block");}catch(e){}
        }else{
            $("#panel_rally").slideDown("fast"); 
			try{$('#form_search').find("#pid").css("display", "none");}catch(e){}
			try{$('#latest_ctn').css("display", "none");}catch(e){}
        }
    } 
    function ShowTopUser2(){ 
        if($("#panel_rally_listen").css("display")=="block"){
            $("#panel_rally_listen").slideUp("fast"); 
			try{$('#form_search').find("#pid").css("display", "inline");}catch(e){}
			try{$('#latest_ctn').css("display", "block");}catch(e){}
        }else{
            $("#panel_rally_listen").slideDown("fast"); 
			try{$('#form_search').find("#pid").css("display", "none");}catch(e){}
			try{$('#latest_ctn').css("display", "none");}catch(e){}
        }
    } 
//